package innerclass;

/**
 * Created by xiebang
 * Description
 * User:小谢
 * Date:2021-10-25
 * Time:9:22
 */

class OuterClass{
    public int data1 = 1;
    public static int data2 = 2;
    private int data3 = 3;
    /*
    在实例内部类中 是不可以定义一个静态的成员变量。
    静态的不依靠对象，非要用要怎么办   加个 final常量在编译的时候就确定 所以就可以

        OuterClass outerClass = new OuterClass();
        OuterClass.InnerClass innerClass = outerClass.new InnerClass();
        3.在实例内部类中是包含外部类的this的，你可以通过外部类名.this来找到。
        4.实例内部类对象，一定要实例化外部类
     */
    class InnerClass{
        public int data1 = 1111;
        public int data4 = 4;
        public static  final int data5 = 5;//
        //
        //
        private int data6 = 6;
        public void  func(){
            System.out.println("这是一个实例内部类的func方法");
            System.out.println(OuterClass.this.data1);
            System.out.println(this.data1);
            System.out.println(data2);
            System.out.println(data3);
            System.out.println(data4);
            System.out.println(data5);
            System.out.println(data6);
        }
    }
}
public class TestDemo {
    public static void main(String[] args) {
        OuterClass outerClass = new OuterClass();
        OuterClass.InnerClass innerClass = outerClass.new InnerClass();
        innerClass.func();
        System.out.println();
    }
}
